package com.shungen.apicloud.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.shungen.apicloud.mapper.InterfaceLabelRelationshipMapper;
import com.shungen.apicloud.model.entity.InterfaceLabel;
import com.shungen.apicloud.model.entity.InterfaceLabelRelationship;
import com.shungen.apicloud.service.InterfaceLabelRelationshipService;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.stream.Collectors;

/**
* @author shungen
* @description 针对表【interface_label_relationship】的数据库操作Service实现
* @createDate 2024-08-05 22:15:19
*/
@Service
public class InterfaceLabelRelationshipServiceImpl extends ServiceImpl<InterfaceLabelRelationshipMapper, InterfaceLabelRelationship>
    implements InterfaceLabelRelationshipService {

    @Override
    public List<Long> getRelationShipIdByInterfaceId(Long id) {
        LambdaQueryWrapper<InterfaceLabelRelationship> interfaceLabelRelationshipLambdaQueryWrapper = new LambdaQueryWrapper<>();
        interfaceLabelRelationshipLambdaQueryWrapper.eq(InterfaceLabelRelationship::getInterfaceId,id);
        List<InterfaceLabelRelationship> interfaceLabelRelationshipList = this.baseMapper.selectList(interfaceLabelRelationshipLambdaQueryWrapper);
        List<Long> relationShipIdList = interfaceLabelRelationshipList.stream().map(InterfaceLabelRelationship::getId).collect(Collectors.toList());
        return relationShipIdList;
    }

    @Override
    public List<Long> getInterfaceLabelIdByInterfaceId(Long id) {
        LambdaQueryWrapper<InterfaceLabelRelationship> interfaceLabelRelationshipLambdaQueryWrapper = new LambdaQueryWrapper<>();
        interfaceLabelRelationshipLambdaQueryWrapper.eq(InterfaceLabelRelationship::getInterfaceId,id);
        List<InterfaceLabelRelationship> interfaceLabelRelationshipList = this.baseMapper.selectList(interfaceLabelRelationshipLambdaQueryWrapper);
        List<Long> labelIdList = interfaceLabelRelationshipList.stream().map(InterfaceLabelRelationship::getLabelId).collect(Collectors.toList());
        return labelIdList;
    }


}




